﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using Software_2Project.DB_Layer;
using System.Text.RegularExpressions;

namespace Software_2Project.Logic_Layer
{
   public class Logic_Deposite
    {
        public bool deposite(Int32 acconum, Int32 balance)
        {
            //=================Validating Empty
            if (acconum.ToString() == null || balance < 0 || balance.ToString() == null)
                return false;
            //=================Validating Numbers Only
            string patternWithdraw = @"^\d+$";
            bool matchDeposite = Regex.IsMatch(balance.ToString(), patternWithdraw);
            bool matchDeposite_1 = Regex.IsMatch(acconum.ToString(), patternWithdraw);

            if (matchDeposite == false || matchDeposite_1 == false)
                return false;



            DB_Deposite let = new DB_Deposite();
            //let.balance = balance;
            //let.acconum = acconum;

            
            DataTable dt = let.deposite(acconum, balance);

            bool excuted = false;

            foreach (DataRow dRow in dt.Rows)
            {

                if ((acconum == int.Parse(dRow["acconum"].ToString())))
                {
            
                    excuted = true;

                }

            }

            return excuted;
            
        }

        public string acconum { get; set; }
    }
}
